//导入返回按钮组件 BackTopv.vue
import BackTop from 'components/content/backTop/BackTop.vue'

//导入防抖函数
import {debounce} from 'common/utils.js'
	
export const itemListenerMixin = {
	data(){
		return {
			itemImgListener: null
		}
	},
	mounted(){
		//1.防抖函数
		const refresh = debounce(this.$refs.scroll.refresh, 200)
		
		this.itemImgListener = ()=>{
			refresh()
		}
		
		//2.监听图片加载完成事件
		this.$bus.$on('itemImageLoad', this.itemImgListener)
		
		//console.log('我是混入中的内容~~~')	
	}
}
	
export const backTopMixin = {
	components: {
		BackTop 
	},
	data(){
		return {
			isShowBackTop: false
		}
	},
	methods: {
		setShowBackTop(position){
			//判断BackTop组件是否显示
			//console.log(position.y)
			this.isShowBackTop = (-position.y) > 1000
		},
		
		//返回按钮点击事件的回调函数
		backClick(){
			//console.log('返回按钮被点击了~~~')
			
			this.$refs.scroll.scrollTo(0, 0, 1000)
		},
	}
}

